﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StorageInfoForm.aspx.cs"
    Inherits="PSS.WebSite.SetManage.BasicData.StorageInfoForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>添加编辑仓库</title>
    <script src="../../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" method="post">
    <input name="StorageId" class="mini-hidden" />
    <div style="padding-left: 11px; padding-bottom: 5px;">
        <table style="table-layout: fixed; width: 100%;">
            <tr>
                <td style="width: 70px;" align="right">
                    仓库编号：
                </td>
                <td style="width: 300px;">
                    <input name="StorageCode" class="mini-textbox" style="width: 300px;" required="true" />
                </td>
            </tr>
            <tr>
                <td style="width: 70px;" align="right">
                    仓库名称：
                </td>
                <td style="width: 300px;">
                    <input name="StorageName" class="mini-textbox" style="width: 300px;" required="true" />
                </td>
            </tr>
            <tr>
                <td style="width: 70px;" align="right">
                    状态：
                </td>
                <td style="width: 300px;">
                    <select name="Status" class="mini-radiobuttonlist">
                        <option value="0">已禁用</option>
                        <option value="1">已启用</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 70px;" align="right">
                    备注：
                </td>
                <td style="width: 300px;">
                    <input name="Remark" class="mini-textarea" style="width: 300px; height: 50px;" />
                </td>
            </tr>
        </table>
    </div>
    <div style="text-align: center; padding: 10px;">
        <a class="mini-button" iconcls="icon-save" onclick="onOk" style="width: 60px; margin-right: 20px;">
            保存</a> <a class="mini-button" iconcls="icon-cancel" onclick="onCancel" style="width: 60px;">
                取消</a>
    </div>
    </form>
    <script type="text/javascript">
        mini.parse();
        mini.getbyName("Status").setValue("1");
        var form = new mini.Form("form1");
        var action;
        function SaveData() {
            var o = form.getData();
            var json = mini.encode([o]);
            form.validate();
            if (form.isValid() == false) return;
            if (action == "edit") {
                $.ajax({
                    url: "../../Service/SetManageHandler.ashx?action=ModifyStorage",
                    data: { data: json },
                    type: 'POST',
                    success: function (text) {
                        CloseWindow("save");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                    }
                });
            }
            else {
                $.ajax({
                    url: "../../Service/SetManageHandler.ashx?action=AddStorage",
                    data: { data: json },
                    type: 'POST',
                    success: function (text) {
                        CloseWindow("save");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                    }
                });
            }
        }

        ////////////////////
        //标准方法接口定义
        function SetData(data) {
            if (data.action == "edit") {
                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
                action = data.action;
                $.ajax({
                    url: "../../service/SetManageHandler.ashx?action=GetStorageInfo&StorageId=" + data.StorageId,
                    cache: false,
                    success: function (text) {
                        var o = mini.decode(text);
                        form.setData(o);
                        form.setChanged(false);
                        if (o.Status) {
                            mini.getbyName("Status").setValue("1");
                        }
                        else {
                            mini.getbyName("Status").setValue("0");
                        }
                    }
                });
            }
        }

        function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }

        function onOk(e) {
            SaveData();
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }

    </script>
</body>
</html>
